package com.zigong.app.http.retrofit;

import android.content.Context;
import android.os.AsyncTask;
import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
import android.util.Log;

import com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import com.jiongbull.jlog.JLog;
import com.ruihang.generalibrary.utils.GeneraLifeObser;
import com.ruihang.generalibrary.utils.UrlUtils;
import com.zigong.app.application.Constances;
import com.zigong.app.beans.ADynamicsItem;
import com.zigong.app.beans.AFileItem;
import com.zigong.app.beans.AHomePageItem;
import com.zigong.app.beans.ARecomdList;
import com.zigong.app.beans.AdPicItem;
import com.zigong.app.beans.AddrInfo;
import com.zigong.app.beans.AddrInfoItem;
import com.zigong.app.beans.AdvertBean;
import com.zigong.app.beans.AdvertDataVo;
import com.zigong.app.beans.AnchorList;
import com.zigong.app.beans.AttitudesBean;
import com.zigong.app.beans.ChatItem;
import com.zigong.app.beans.ChooseCityBean;
import com.zigong.app.beans.ChooseCityVo;
import com.zigong.app.beans.ContentImage;
import com.zigong.app.beans.ConvertRecordBean;
import com.zigong.app.beans.FCityItem;
import com.zigong.app.beans.FCityState;
import com.zigong.app.beans.FComment;
import com.zigong.app.beans.FLive;
import com.zigong.app.beans.FLiveDy;
import com.zigong.app.beans.FNews;
import com.zigong.app.beans.FOrganDetail;
import com.zigong.app.beans.FProgram;
import com.zigong.app.beans.FRebellion;
import com.zigong.app.beans.FScribeState;
import com.zigong.app.beans.FSubscribe;
import com.zigong.app.beans.FUsers;
import com.zigong.app.beans.FVersionInfo;
import com.zigong.app.beans.FocusColumn;
import com.zigong.app.beans.GoodsBeanInfo;
import com.zigong.app.beans.GovBean;
import com.zigong.app.beans.GovDetailBean;
import com.zigong.app.beans.GovItemBean;
import com.zigong.app.beans.HighRiseBean;
import com.zigong.app.beans.HighRiseVo;
import com.zigong.app.beans.HomePopular;
import com.zigong.app.beans.IntegralAddBean;
import com.zigong.app.beans.InvitationRuleVo;
import com.zigong.app.beans.LicenseKeyItem;
import com.zigong.app.beans.LiveAdvance;
import com.zigong.app.beans.LiveItem;
import com.zigong.app.beans.MessageListVo;
import com.zigong.app.beans.MessageStateBean;
import com.zigong.app.beans.NewsClickBean;
import com.zigong.app.beans.NewsDate;
import com.zigong.app.beans.NewsItem;
import com.zigong.app.beans.RebllionCommitResult;
import com.zigong.app.beans.ResidualIntegral;
import com.zigong.app.beans.SearchKeyWords;
import com.zigong.app.beans.SearchResult;
import com.zigong.app.beans.ServiceBean;
import com.zigong.app.beans.ServiceConfigBean;
import com.zigong.app.beans.ServiceVo;
import com.zigong.app.beans.SignInfo;
import com.zigong.app.beans.ServiceCityListVo;
import com.zigong.app.beans.SingleResult;
import com.zigong.app.beans.TopicContent;
import com.zigong.app.beans.TopicVo;
import com.zigong.app.beans.TvLivingList;
import com.zigong.app.beans.UserInfoBean;
import com.zigong.app.beans.VoteInfo;
import com.zigong.app.beans.VoteOption;
import com.zigong.app.http.INetAdapter;
import com.zigong.app.http.INetCallback;
import com.zigong.app.http.IPage;
import com.zigong.app.http.NetResponseObject;
import com.zigong.app.http.NetResponseObjectArray;
import com.zigong.app.http.NetServer;
import com.zigong.app.http.Params;
import com.zigong.app.http.retrofit.inf.NetRetrofitInfs;
import com.zigong.app.utils.UserManager;

import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.RequestBody;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.converter.scalars.ScalarsConverterFactory;
import retrofit2.http.FieldMap;
import retrofit2.http.Path;

/**
 * Created by Administrator on 2017/7/6.
 */

public class RetrofitNetServer implements NetServer, INetAdapter {

    private final String baseUrl = Constances.DY_BASE_URL;//baseurl移至Constances类,相关url改动在Constances类中修改
    private final String mallBaseUrl = Constances.MALL_DY_BASE_URL;//baseurl移至Constances类,相关url改动在Constances类中修改
    private final String logBaseUrl = Constances.ST_LOG_BASE_URL;//统计日志服务器地址
//    private final String sBaseUrl = "http://192.168.17.62/";//测试环境http://192.168.17.62/sctv/index.json

    private final String TEST_TAG = "test";

    public static final String LIST_URL_END = ".json";

    public final String ERROR_CATCH = "catch_error";
    public final String ERROR_FAILD = "faild_error";

    private Retrofit retrofit;
    private Retrofit mallRetrofit;
    private Retrofit logRetrofit;
    private NetRetrofitInfs netRetrofitInfs;
    private NetRetrofitInfs mallNetRetrofitInfs;
    private NetRetrofitInfs logNetRetrofitInfs;

    @Override
    public <T> void get(String method, INetCallback<T> callback) {

    }

    @Override
    public <T> void post(String method, Params params, INetCallback<T> callback) {

    }

    @Override
    public void setContext(Context context) {

    }

    @Override
    public boolean hasSetContext() {
        return false;
    }

    private Retrofit getRetrofit() {
        if (retrofit == null) {
            HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
            httpLoggingInterceptor.setLevel(Constances.IS_TESTING ? HttpLoggingInterceptor.Level.HEADERS : HttpLoggingInterceptor.Level.NONE);
     //       httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY );

            OkHttpClient client = new OkHttpClient.Builder()
                    .addInterceptor(httpLoggingInterceptor)
                    .readTimeout(30, TimeUnit.SECONDS).writeTimeout(30, TimeUnit.SECONDS).build();
            retrofit = new Retrofit.Builder().client(client)
                    .baseUrl(baseUrl)
                    //增加返回值为String的支持
                    .addConverterFactory(ScalarsConverterFactory.create())
                    //增加返回值为Gson的支持(以实体类返回)
                    .addConverterFactory(GsonConverterFactory.create())
//                //增加返回值为Oservable<T>的支持
                    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                    .build();
        }
        return retrofit;
    }

    private Retrofit getMallRetrofit() {
        if (mallRetrofit == null) {
            HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
            httpLoggingInterceptor.setLevel(Constances.IS_TESTING ? HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.NONE);
            OkHttpClient client = new OkHttpClient.Builder()
                    .addInterceptor(httpLoggingInterceptor)
                    .readTimeout(30, TimeUnit.SECONDS).writeTimeout(30, TimeUnit.SECONDS).build();
            mallRetrofit = new Retrofit.Builder().client(client)
                    .baseUrl(mallBaseUrl)
                    //增加返回值为String的支持
                    .addConverterFactory(ScalarsConverterFactory.create())
                    //增加返回值为Gson的支持(以实体类返回)
                    .addConverterFactory(GsonConverterFactory.create())
//                //增加返回值为Oservable<T>的支持
                    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                    .build();
        }
        return mallRetrofit;
    }

    private Retrofit getLogRetrofit() {
        if (logRetrofit == null) {
            HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
            httpLoggingInterceptor.setLevel(Constances.IS_TESTING ? HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.NONE);
            OkHttpClient client = new OkHttpClient.Builder()
                    .addInterceptor(httpLoggingInterceptor)
                    .readTimeout(30, TimeUnit.SECONDS).writeTimeout(30, TimeUnit.SECONDS).build();
            logRetrofit = new Retrofit.Builder().client(client)
                    .baseUrl(logBaseUrl)
                    //增加返回值为String的支持
                    .addConverterFactory(ScalarsConverterFactory.create())
                    //增加返回值为Gson的支持(以实体类返回)
                    .addConverterFactory(GsonConverterFactory.create())
//                //增加返回值为Oservable<T>的支持
                    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                    .build();
        }
        return logRetrofit;
    }

    private String getPageUrl(String method, int calledIndex) {
        String hole = getHoleUrl(method);
        if (hole.endsWith(LIST_URL_END) && calledIndex > 0) {
            int index = hole.lastIndexOf(".");
            if (index > 0) {
                hole = hole.substring(0, index) + "_" + calledIndex + ".json";
            }
        }
        return hole;
    }

    private String getHoleUrl(String method) {
        return UrlUtils.linkUrls(Constances.ST_BASE_URL, method);
    }

    private String getMallHoleUrl(String method) {
        return UrlUtils.linkUrls(Constances.MALL_DY_BASE_URL, method);
    }

    /**
     * 初始  新闻等相关服务
     *
     * @return
     */
    private NetRetrofitInfs getNetAdapterService() {
        if (netRetrofitInfs == null) {
            netRetrofitInfs = getRetrofitService(NetRetrofitInfs.class);
        }
        return netRetrofitInfs;
    }

    private <T> T getRetrofitService(Class<T> cls) {
        return getRetrofit().create(cls);
    }

    /**
     * 商城相关服务
     *
     * @return
     */
    private NetRetrofitInfs getMallNetAdapterService() {
        if (mallNetRetrofitInfs == null) {
            mallNetRetrofitInfs = getMallRetrofitService(NetRetrofitInfs.class);
        }
        return mallNetRetrofitInfs;
    }

    /**
     * 商城相关服务
     *
     * @return
     */
    private <T> T getMallRetrofitService(Class<T> cls) {
        return getMallRetrofit().create(cls);
    }

    /**
     * 日志统计相关服务
     *
     * @return
     */
    private NetRetrofitInfs getLogNetAdapterService() {
        if (logNetRetrofitInfs == null) {
            logNetRetrofitInfs = getLogRetrofitService(NetRetrofitInfs.class);
        }
        return logNetRetrofitInfs;
    }

    /**
     * 日志统计相关服务
     *
     * @return
     */
    private <T> T getLogRetrofitService(Class<T> cls) {
        return getLogRetrofit().create(cls);
    }

    /**
     * 获取列表数据，使用asynctask线程进行网络访问，对结果进行处理
     *
     * @param tCall
     * @param callback
     * @param <T>
     */
    private <T> void doNetAsync(String owner, Call<NetResponseObjectArray<T>> tCall, INetCallback<List<T>> callback
            , final String logTag) {
        new NetAsync<NetResponseObjectArray<T>, List<T>>(owner, tCall, callback) {

            NetResponseObjectArray<T> nr;

            String msg;

            Throwable t;
            int netcode = INetCallback.NET_CODE_UNCONNECT;

            @Override
            protected Void doInBackground(Void... voids) {
                try {
                    Response<NetResponseObjectArray<T>> response = call.execute();
                    if (response == null) {
                        msg = "can't get response";
                        netcode = INetCallback.NET_CODE_NULLDATA;
                    } else if (!response.isSuccessful()) {
                        msg = response.message();
                        if (TextUtils.isEmpty(msg)) {
                            msg = response.errorBody().string();
                        }
                        netcode = response.code();
                    } else {
                        nr = response.body();
//                        JLog.e(logTag + " $ nr: " + nr);
                        setPageResponse(callbackTemp, nr);
                        if (nr == null) {
                            msg = "response is return null body";
                            netcode = response.code();
                        } else if (nr.isNetOk() && GeneraLifeObser.isOwnerLife(ownerString)) {
                            List<T> list = callbackTemp.doInBackground(nr.getData().getList());
                            if (list != null && list != nr.getData()) {
                                nr.getData().setList(list);
                            }
                            nr.whenSucdoOthers(nr);
                            netcode = nr.getRs();
                        } else {
                            msg = nr.getError();
                            netcode = nr.getRs();
                        }

                    }
                    if (netcode == INetCallback.NET_CODE_USER_ERROR) {
                        UserManager.getInstance().setLoginExpired(true);
                        JLog.e("====NET_CODE_USER_ERROR=======", "netcode=" + netcode);
                        if (callbackTemp.whenLoginExpiredBackGround()) {
                            publishProgress();
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    t = e;
                    msg = ERROR_CATCH + " " + e.toString();
                }
                return null;
            }

            @Override
            protected void onProgressUpdate(Void... values) {
                UserManager.onUserExpired();
            }

            @Override
            protected void onPostExecute(Void aVoid) {
                if (!GeneraLifeObser.isOwnerLife(ownerString)) {
                    return;
                }
                if (!TextUtils.isEmpty(msg) || nr == null || netcode != 200) {
                    JLog.e(logTag + " $ in error :  msg:" + msg + "  nr:" + nr);
                    callbackTemp.onError(t, msg, netcode);
                } else {
                    JLog.e(logTag + " $ in onSuc :  msg:" + nr.getData().getList());
                    callbackTemp.onSuc(nr.getData().getList());
                }
                callbackTemp.onEnd();
            }
        }.ex();
    }

    /**
     * 获取分页数据，使用asynctask线程进行网络访问，对结果进行处理
     *
     * @param tCall
     * @param callback
     * @param <T>
     */
    private <T> void doNetPageAsync(String owner, Call<NetResponseObjectArray<T>> tCall, INetCallback<NetResponseObjectArray<T>> callback) {
        new NetAsync<NetResponseObjectArray<T>, NetResponseObjectArray<T>>(owner, tCall, callback) {

            NetResponseObjectArray<T> nr;

            String msg;

            Throwable t;

            int netcode = INetCallback.NET_CODE_UNCONNECT;

            @Override
            protected Void doInBackground(Void... voids) {
                try {
                    Response<NetResponseObjectArray<T>> response = call.execute();
//                    JLog.e(response.);
                    if (response == null) {
                        msg = "can't get response";
                        netcode = INetCallback.NET_CODE_NULLDATA;
                    } else if (!response.isSuccessful()) {
                        msg = response.message();
                        if (TextUtils.isEmpty(msg)) {
                            msg = response.errorBody().string();
                        }
                        netcode = response.code();
                    } else {
                        nr = response.body();
                        if (nr == null) {
                            msg = "response is return null body";
                            netcode = response.code();
                        } else if (nr.isNetOk() && GeneraLifeObser.isOwnerLife(ownerString)) {
                            NetResponseObjectArray<T> nro = callbackTemp.doInBackground(nr);
                            if (nro != null && nr != nro) {
                                nr = nro;
                            }
                            nr.whenSucdoOthers(nr);
                            netcode = nr.getRs();
                        } else {
                            msg = nr.getError();
                            netcode = nr.getRs();
                        }
                    }
                    if (netcode == INetCallback.NET_CODE_USER_ERROR) {
                        JLog.e("====NET_CODE_USER_ERROR=======", "netcode=" + netcode);
                        UserManager.getInstance().setLoginExpired(true);
                        publishProgress();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    t = e;
                    msg = ERROR_CATCH + " " + e.toString();
                }
                return null;
            }

            @Override
            protected void onProgressUpdate(Void... values) {
                UserManager.onUserExpired();
            }

            @Override
            protected void onPostExecute(Void aVoid) {
                if (!GeneraLifeObser.isOwnerLife(ownerString)) {
                    return;
                }
                if (!TextUtils.isEmpty(msg) || nr == null || netcode != 200) {
                    callbackTemp.onError(t, msg, netcode);
                } else {
                    callbackTemp.onSuc(nr);
                }
                callbackTemp.onEnd();
            }
        }.ex();
    }

    /**
     * 获取对象型的数据，使用asynctask线程进行网络访问，对结果进行处理
     *
     * @param tCall
     * @param callback
     * @param <T>
     */
    private <T> void doNetObjAsync(String owner, Call<NetResponseObject<T>> tCall, INetCallback<T> callback) {
        new NetAsync<NetResponseObject<T>, T>(owner, tCall, callback) {

            NetResponseObject<T> nr;

            String msg;

            Throwable t;

            int netcode = INetCallback.NET_CODE_UNCONNECT;

            @Override
            protected Void doInBackground(Void... voids) {
                try {
                    Response<NetResponseObject<T>> response = call.execute();
                    if (response == null) {
                        msg = "can't get response";
                        netcode = INetCallback.NET_CODE_NULLDATA;
                    } else if (!response.isSuccessful()) {
                        msg = response.message();
                        if (TextUtils.isEmpty(msg)) {
                            msg = response.errorBody().string();
                        }
                        netcode = response.code();
                    } else {
                        nr = response.body();
                        if (nr == null) {
                            msg = "response is return null body";
                            netcode = response.code();
                        } else if (nr.isNetOk() && GeneraLifeObser.isOwnerLife(ownerString)) {
                            T t = callbackTemp.doInBackground(nr.getData());
                            if (t != null && t != nr.getData()) {
                                nr.setData(t);
                            }
                            nr.whenSucdoOthers(nr);
                            netcode = nr.getRs();
                        } else {
                            msg = nr.getError();
                            netcode = nr.getRs();
                        }
                    }
                    if (netcode == INetCallback.NET_CODE_USER_ERROR) {
                        JLog.e("====NET_CODE_USER_ERROR=======", "netcode=" + netcode);
                        UserManager.getInstance().setLoginExpired(true);
                        if (callbackTemp.whenLoginExpiredBackGround()) {
                            publishProgress();
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    t = e;
                    msg = ERROR_CATCH + " " + e.toString();
                }
                return null;
            }

            @Override
            protected void onProgressUpdate(Void... values) {
                UserManager.onUserExpired();
            }

            @Override
            protected void onPostExecute(Void aVoid) {
                if (!GeneraLifeObser.isOwnerLife(ownerString)) {
                    return;
                }
                if (!TextUtils.isEmpty(msg) || nr == null || netcode != 200) {
                    callbackTemp.onError(t, msg, netcode);
                } else {
                    callbackTemp.onSuc(nr.getData());
                }
                callbackTemp.onEnd();
            }
        }.ex();
    }

    /**
     * 获取字符数据，使用asynctask线程进行网络访问，对结果进行处理
     *
     * @param tCall
     * @param callback
     */
    private void doNetStringAsync(String owner, Call<String> tCall, INetCallback<String> callback) {
        new NetAsync<String, String>(owner, tCall, callback) {

            String nr;

            String msg;

            Throwable t;

            int netcode = INetCallback.NET_CODE_UNCONNECT;

            @Override
            protected Void doInBackground(Void... voids) {
                try {
                    Response<String> response = call.execute();
                    if (response == null) {
                        msg = "can't get response";
                        netcode = INetCallback.NET_CODE_NULLDATA;
                    } else if (!response.isSuccessful()) {
                        setRequestUrl(callbackTemp, response);
                        msg = response.message();
                        if (TextUtils.isEmpty(msg)) {
                            msg = response.errorBody().string();
                        }
                        netcode = response.code();
                    } else {
                        setRequestUrl(callbackTemp, response);
                        nr = response.body();
                        netcode = response.code();
                        if (nr == null) {
                            msg = "response is return null body";
                            netcode = response.code();
                        } else {
                            if (GeneraLifeObser.isOwnerLife(ownerString)) {
                                String str = callbackTemp.doInBackground(nr);
                                if (str != null && !TextUtils.equals(str, nr)) {
                                    nr = str;
                                }
                            }
//                            nr.whenSucdoOthers(nr);
//                            netcode = nr.getRs();
                        }
                    }
//                    if (netcode == INetCallback.NET_CODE_USER_ERROR) {
//                        UserManager.getInstance().setLoginExpired(true);
//                        publishProgress();
//                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    t = e;
                    msg = ERROR_CATCH + " " + e.toString();
                }
                return null;
            }

            @Override
            protected void onProgressUpdate(Void... values) {
                UserManager.onUserExpired();
            }

            @Override
            protected void onPostExecute(Void aVoid) {
                if (!GeneraLifeObser.isOwnerLife(ownerString)) {
                    return;
                }
                if (!TextUtils.isEmpty(msg) || nr == null || netcode != 200) {
                    callbackTemp.onError(t, msg, netcode);
                } else {
                    callbackTemp.onSuc(nr);
                }
                callbackTemp.onEnd();
            }
        }.ex();
    }

    @Override
    public <T> Call<NetResponseObject<T>> getObj(String url, boolean isHole, INetCallback<T> callback) {
        if (TEST_TAG.equals(url)) {
            doTestObjAsync(callback);
            return null;
        }
        Call<NetResponseObject<T>> call = null;
        if (isHole) {
            call = getNetAdapterService().getObjNullParam(url);
        } else {
            call = getNetAdapterService().getObjNullParamP(url);
        }
        doNetObjAsync("", call, callback);
        return call;
    }

    @Override
    public <T> Call<NetResponseObjectArray<T>> getArray(String url, boolean isHole, INetCallback<List<T>> callback) {
        if (TEST_TAG.equals(url)) {
            doTestAsync(callback);
            return null;
        }
        Call<NetResponseObjectArray<T>> call = null;
        if (isHole) {
            call = getNetAdapterService().getArrayNullParam(url);
        } else {
            call = getNetAdapterService().getArrayNullParamP(url);
        }
        doNetAsync("", call, callback, url);
        return call;
    }

    @Override
    public <T> Call<NetResponseObject<T>> getObjPost(String method, Map<String, Object> param, INetCallback<T> callback) {
        if (TEST_TAG.equals(method)) {
            doTestObjAsync(callback);
            return null;
        }
        Call<NetResponseObject<T>> call = null;
        if (param == null || param.size() == 0) {
            call = getNetAdapterService().postObjNullParam(method);
        } else {
            call = getNetAdapterService().postObjParam(method, param);
        }
        doNetObjAsync("", call, callback);
        return call;
    }

    @Override
    public <T> Call<?> getArrayPostPage(String method, Map<String, Object> param, INetCallback<NetResponseObjectArray<T>> callback) {
        if (TEST_TAG.equals(method)) {
            doTestPageAsync(callback);
            return null;
        }
        Call<NetResponseObjectArray<T>> call = null;
        if (param == null || param.size() == 0) {
            call = getNetAdapterService().postArrayNullParam(method);
        } else {
            call = getNetAdapterService().postArrayParam(method, param);
        }
        doNetPageAsync("", call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<FocusColumn>> getChannelArray(String owner, String method, INetCallback<List<FocusColumn>> callback) {
        Call<NetResponseObjectArray<FocusColumn>> call = getNetAdapterService().getChannelArray(getHoleUrl(method));
        doNetAsync(owner, call, callback, method);
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<NewsItem>> getNewsArray(String owner, String method, INetCallback<List<NewsItem>> callback) {
        Call<NetResponseObjectArray<NewsItem>> call = getNetAdapterService().getNewsArray(getHoleUrl(method));
        doNetAsync(owner, call, callback, method);
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<NewsDate>> getNewsDateArray(String owner, String method, INetCallback<List<NewsDate>> callback) {
        Call<NetResponseObjectArray<NewsDate>> call = getNetAdapterService().getNewsDate(getHoleUrl(method));
        doNetAsync(owner, call, callback, method);
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<NewsItem>> getNewsPage(String owner, String method, int calledIndex, INetCallback<List<NewsItem>> callback) {
        Call<NetResponseObjectArray<NewsItem>> call = getNetAdapterService().getNewsArray(getPageUrl(method, calledIndex));
        doNetAsync(owner, call, callback, method);
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<LiveItem>> getLiveArray(String owner, String method, INetCallback<List<LiveItem>> callback) {
        Call<NetResponseObjectArray<LiveItem>> call = getNetAdapterService().getLiveArray(getHoleUrl(method));
        doNetAsync(owner, call, callback, method);
        return call;
    }

    @Override
    public Call<NetResponseObject<HighRiseBean>> getHighRiseList(String owner, String url, INetCallback<HighRiseBean> callback) {
        Call<NetResponseObject<HighRiseBean>> call = getNetAdapterService().getHighRiseList(getHoleUrl(url));
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<FProgram>> getProgramArray(String owner, String method, INetCallback<List<FProgram>> callback) {
        Call<NetResponseObjectArray<FProgram>> call = getNetAdapterService().getProgramArray(getHoleUrl(method));
        doNetAsync(owner, call, callback, method);
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<ADynamicsItem>> getDynamicsPage(String owner, String method, int calledIndex, INetCallback<List<ADynamicsItem>>
            callback) {
        Call<NetResponseObjectArray<ADynamicsItem>> call = getNetAdapterService().getDynamicsPage(getPageUrl(method, calledIndex));
        doNetAsync(owner, call, callback, method);
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<FRebellion>> getRebellionPage(String owner, String method, int calledIndex, INetCallback<List<FRebellion>> callback) {
        Call<NetResponseObjectArray<FRebellion>> call = getNetAdapterService().getRebellionArray(getPageUrl(method, calledIndex));
        doNetAsync(owner, call, callback, method);
        return call;
    }

    @Override
    public Call<NetResponseObject<TvLivingList>> getTvLivingList(String owner, String method, INetCallback<TvLivingList> callback) {
        Call<NetResponseObject<TvLivingList>> call = getNetAdapterService().getTvLivingList(getHoleUrl(method));
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<FLive>> getLiveInfo(String owner, String method, INetCallback<FLive> callback) {
        Call<NetResponseObject<FLive>> call = getNetAdapterService().getLiveInfo(getHoleUrl(method));
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<AnchorList>> getAnchorList(String owner, String method, INetCallback<AnchorList> callback) {
        Call<NetResponseObject<AnchorList>> call = getNetAdapterService().getAnchorList(getHoleUrl(method));
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<AHomePageItem>> getAHomePageList(String owner, String method, int calledIndex, INetCallback<AHomePageItem> callback) {
        Call<NetResponseObject<AHomePageItem>> call = getNetAdapterService().getAHomePageList(getPageUrl(method, calledIndex));
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<ARecomdList>> getRecommList(String owner, String method, int calledIndex, INetCallback<ARecomdList> callback) {
        Call<NetResponseObject<ARecomdList>> call = getNetAdapterService().getRecommList(getPageUrl(method, calledIndex));
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<FProgram>> getProgramList(String owner, String method, int calledIndex, INetCallback<List<FProgram>> callback) {
        Call<NetResponseObjectArray<FProgram>> call = getNetAdapterService().getProgramList(getPageUrl(method, calledIndex));
        doNetAsync(owner, call, callback, method);
        return call;
    }

    @Override
    public Call<NetResponseObject<FCityItem>> getStateList(String owner, String method, INetCallback<FCityItem> callback) {
        Call<NetResponseObject<FCityItem>> call = getNetAdapterService().getStateList(getHoleUrl(method));
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<FOrganDetail>> getOrganList(String owner, String method, int calledIndex, INetCallback<FOrganDetail> callback) {
        Call<NetResponseObject<FOrganDetail>> call = getNetAdapterService().getOrganList(getPageUrl(method, calledIndex));
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<FSubscribe>> getSubscribeListPage(String owner, String method, int calledIndex, INetCallback<List<FSubscribe>> callback) {
        Call<NetResponseObjectArray<FSubscribe>> call = getNetAdapterService().getSubscribeListPage(getPageUrl(method, calledIndex));
        doNetAsync(owner, call, callback, method);
        return call;
    }

//    @Override
//    public Call<NetResponseObjectArray<FSubscribe>> getSubscribeListPage(String method, int calledIndex, INetCallback<List<FSubscribe>> callback) {
//        Call<NetResponseObjectArray<FProgram>> call = getNetAdapterService().getSubscribeListPage(getPageUrl(method, calledIndex));
//        doNetAsync(call, callback, method);
//        return call;
//    }

    @Override
    public Call<NetResponseObject<SingleResult>> postGetSingle(String owner, String method, Map<String, Object> param, INetCallback<SingleResult> callback) {
        Call<NetResponseObject<SingleResult>> call = getNetAdapterService().postGetSingle(method, param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<FUsers>> postLogin(String owner, Map<String, Object> param, INetCallback<FUsers> callback) {
        Call<NetResponseObject<FUsers>> call = getNetAdapterService().postLogin(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<RebllionCommitResult>> postRebellion(String owner, ArrayMap<String, Object> param, INetCallback<RebllionCommitResult> callback) {
        Call<NetResponseObject<RebllionCommitResult>> call = getNetAdapterService().postRebellion(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<SingleResult>> postAnchor(String owner, ArrayMap<String, Object> param, INetCallback<SingleResult> callback) {
        Call<NetResponseObject<SingleResult>> call = getNetAdapterService().postAnchor(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<SingleResult>> modifyAvatar(String owner, ArrayMap<String, Object> param, String file, INetCallback<SingleResult> callback) {
        MultipartBody.Builder b = new MultipartBody.Builder().setType(MultipartBody.FORM);
        for (int i = 0; i < param.size(); i++) {
            b.addFormDataPart(param.keyAt(i), "" + param.valueAt(i));
        }
        File f = new File(file);
        RequestBody rb = RequestBody.create(MediaType.parse("image/*"), f);
        b.addFormDataPart("avatar", f.getName(), rb);
        Call<NetResponseObject<SingleResult>> call = getNetAdapterService().modifyAvatar(b.build());
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<FCityState>> getUserOrganList(String owner, ArrayMap<String, Object> param, INetCallback<List<FCityState>> callback) {
        Call<NetResponseObjectArray<FCityState>> call = getNetAdapterService().getUserOrganList(param);
        doNetAsync(owner, call, callback, "getUserOrganList");
        return call;
    }

    @Override
    public Call<NetResponseObject<FScribeState>> getSubscribeState(String owner, Map<String, Object> param, INetCallback<FScribeState> callback) {
        Call<NetResponseObject<FScribeState>> call = getNetAdapterService().getSubscribeState(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<AdPicItem>> getAdList(String owner, String method, INetCallback<AdPicItem> callback) {
        Call<NetResponseObject<AdPicItem>> call = getNetAdapterService().getAdList(getHoleUrl(method));
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<FVersionInfo>> getVersion(String owner, String method, INetCallback<FVersionInfo> callback) {
        Call<NetResponseObject<FVersionInfo>> call = getNetAdapterService().getVersion(getHoleUrl(method));
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<AdvertDataVo>> getAdInfo(String owner, String method, INetCallback<AdvertDataVo> callback) {
        Call<NetResponseObject<AdvertDataVo>> call = getNetAdapterService().getAdInfo(getHoleUrl(method));
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<SearchResult>> getSearchResult(String owner, Map<String, Object> param, INetCallback<SearchResult> callback) {
        Call<NetResponseObject<SearchResult>> call = getNetAdapterService().getSearchResult(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<SearchResult>> keywordOptionSearchFulltext(String owner, Map<String, Object> param, INetCallback<SearchResult> callback) {
        Call<NetResponseObject<SearchResult>> call = getNetAdapterService().keywordOptionSearchFulltext(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<LiveAdvance>> getLiveConfig(String owner, Map<String, Object> param, INetCallback<LiveAdvance> callback) {
        Call<NetResponseObject<LiveAdvance>> call = getNetAdapterService().getLiveConfig(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<LicenseKeyItem>> getLicensekey(String owner, Map<String, Object> param, INetCallback<LicenseKeyItem> callback) {
        Call<NetResponseObject<LicenseKeyItem>> call = getNetAdapterService().getLicensekey(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<String> getStringContent(String owner, String url, INetCallback<String> callback) {
        String u = getHoleUrl(url);
        Call<String> call = getNetAdapterService().getStringContent(u);
        if (callback != null) {
            callback.setSome(u);
        }
        doNetStringAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<VoteInfo>> getVoteInfo(String owner, Map<String, Object> param, INetCallback<VoteInfo> callback) {
        Call<NetResponseObject<VoteInfo>> call = getNetAdapterService().getVoteInfo(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<VoteInfo>> getVoteInfo(String owner, String url, Map<String, Object> param, INetCallback<VoteInfo> callback) {
        Call<NetResponseObject<VoteInfo>> call = getNetAdapterService().getVoteInfo(url, param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<FNews>> getNewsInfo(String owner, String url, INetCallback<FNews> callback) {
        Call<NetResponseObject<FNews>> call = getNetAdapterService().getNewsInfo(getHoleUrl(url));
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<HomePopular>> getHomePopular(String owner, String url, INetCallback<HomePopular> callback) {
        Call<NetResponseObject<HomePopular>> call = getNetAdapterService().getHomePopular(getHoleUrl(url));
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<FComment>> getCommentList(String owner, String sourceId, int requestType, int capacity, int index,
                                                                 INetCallback<List<FComment>> callback) {
        Call<NetResponseObjectArray<FComment>> call = getNetAdapterService().getCommentList(sourceId, requestType, capacity, index);
        doNetAsync(owner, call, callback, "getCommentList");
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<FComment>> getCommentList(String owner, String url, String sourceId, int requestType, int capacity, int index,
                                                                 INetCallback<List<FComment>> callback) {
        Call<NetResponseObjectArray<FComment>> call = getNetAdapterService().getCommentList(url, sourceId, requestType, capacity, index);
        doNetAsync(owner, call, callback, "getCommentList");
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<LiveItem>> getLiveListPage(String owner, String url, int calledIndex, INetCallback<List<LiveItem>> callback) {
        Call<NetResponseObjectArray<LiveItem>> call = getNetAdapterService().getLiveListPage(getPageUrl(url, calledIndex));
        doNetAsync(owner, call, callback, "getLiveListPage");
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<ChatItem>> getLiveChatList(String owner, String sourceId, INetCallback<List<ChatItem>> callback) {
        Call<NetResponseObjectArray<ChatItem>> call = getNetAdapterService().getLiveChatList(sourceId);
        doNetAsync(owner, call, callback, "getLiveChatList");
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<ChatItem>> getLiveChatList(String owner, String url, String sourceId, INetCallback<List<ChatItem>> callback) {
        Call<NetResponseObjectArray<ChatItem>> call = getNetAdapterService().getLiveChatList(url, sourceId);
        doNetAsync(owner, call, callback, "getLiveChatList");
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<VoteOption>> accountVOte(String owner, Map<String, Object> param, INetCallback<List<VoteOption>> callback) {
        Call<NetResponseObjectArray<VoteOption>> call = getNetAdapterService().accountVote(param);
        doNetAsync(owner, call, callback, "accountVote");
        return call;
    }

    @Override
    public Call<NetResponseObject<SingleResult>> uploadImages1(String owner, List<String> files, INetCallback<SingleResult> callback) {
        MultipartBody.Builder b = new MultipartBody.Builder().setType(MultipartBody.FORM);
        b.addFormDataPart(Constances.SITE_NET_KEY, Constances.SITE_ID);
        for (int i = 0; i < files.size(); i++) {
            String fi = files.get(i);
            if (TextUtils.isEmpty(fi)) {
                continue;
            }
            File f = new File(fi);
            RequestBody rb = RequestBody.create(MediaType.parse("image/*"), f);
            b.addFormDataPart("imageData", f.getName(), rb);
        }
        Call<NetResponseObject<SingleResult>> call = getNetAdapterService().uploading("uploadingPictures", b.build());
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<SingleResult>> uploadImages(String owner, List<ContentImage> files, INetCallback<SingleResult> callback) {
        MultipartBody.Builder b = new MultipartBody.Builder().setType(MultipartBody.FORM);
        b.addFormDataPart(Constances.SITE_NET_KEY, Constances.SITE_ID);
        for (int i = 0; i < files.size(); i++) {
            ContentImage image = files.get(i);
            String fi = image.getImageUrl();
            if (TextUtils.isEmpty(fi)) {
                continue;
            }
            File f = new File(fi);
            RequestBody rb = RequestBody.create(MediaType.parse("image/*"), f);
            b.addFormDataPart("imageData", f.getName(), rb);
        }
        Call<NetResponseObject<SingleResult>> call = getNetAdapterService().uploading("uploadingPictures", b.build());
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<SingleResult>> uploadVideo(String owner, String videoFile, final INetCallback<SingleResult> callback) {
//        MultipartBody.Builder b = new MultipartBody.Builder().setType(MultipartBody.FORM);
//        b.addFormDataPart(Constances.SITE_NET_KEY, Constances.SITE_ID);
        File f = new File(videoFile);
        RequestBody rb = RequestBody.create(MediaType.parse("multipart/form-data"), f);
//        RequestBody rb = new FileRequestBody(MediaType.parse("multipart/form-data"), f);
//        b.addFormDataPart("videoData", f.getName(), rb);
        MultipartBody.Part pa = MultipartBody.Part.createFormData("videoData", f.getName(), rb);
        ArrayMap<String, Object> map = new ArrayMap<>();
        map.put(Constances.SITE_NET_KEY, Constances.SITE_ID);
//        Call<NetResponseObject<SingleResult>> call = getNetAdapterService().uploading("uploadingVideos", b.build());
        Call<NetResponseObject<SingleResult>> call = getNetAdapterService().uploading2("uploadingVideos", map, pa);
        JLog.e("vvav  call is " + call);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<SearchKeyWords>> getHotKeyWords(String owner, Map<String, Object> param, INetCallback<SearchKeyWords> callback) {
        Call<NetResponseObject<SearchKeyWords>> call = getNetAdapterService().getHotKeyword(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<NewsItem>> getRelateNews(String owner, String keyword, String newsId, INetCallback<List<NewsItem>> callback) {
        Call<NetResponseObjectArray<NewsItem>> call = getNetAdapterService().getRelateNews(keyword, newsId, Constances.SITE_ID);
        doNetAsync(owner, call, callback, "getRelateNews");
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<NewsItem>> getRelateNews(String owner, String url, String keyword, String newsId, INetCallback<List<NewsItem>> callback) {
        Call<NetResponseObjectArray<NewsItem>> call = getNetAdapterService().getRelateNews(url, keyword, newsId, Constances.SITE_ID);
        doNetAsync(owner, call, callback, "getRelateNews");
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<FLiveDy>> getLiveDynamicList(String owner, String roomId, INetCallback<List<FLiveDy>> callback) {
        Call<NetResponseObjectArray<FLiveDy>> call = getNetAdapterService().getLiveDynamicList(roomId);
        doNetAsync(owner, call, callback, "getLiveDynamicList");
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<FLiveDy>> getLiveDynamicList(String owner, String url, String roomId, INetCallback<List<FLiveDy>> callback) {
        Call<NetResponseObjectArray<FLiveDy>> call = getNetAdapterService().getLiveDynamicList(url, roomId);
        doNetAsync(owner, call, callback, "getLiveDynamicList");
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<ADynamicsItem>> getTimelineList(String owner, Map<String, Object> param, INetCallback<List<ADynamicsItem>> callback) {
        Call<NetResponseObjectArray<ADynamicsItem>> call = getNetAdapterService().getTimelineList(param);
        doNetAsync(owner, call, callback, "getTimelineList");
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<NewsItem>> getAnchorRelateNewsList(String owner, Map<String, Object> param, INetCallback<List<NewsItem>> callback) {
        Call<NetResponseObjectArray<NewsItem>> call = getNetAdapterService().getAnchorRelateNewsList(param);
        doNetAsync(owner, call, callback, "getAnchorRelateNews");
        return call;
    }


    @Override
    public Call<NetResponseObjectArray<AFileItem>> getRadioHostDoc(String owner, Map<String, Object> param, INetCallback<List<AFileItem>> callback) {
        Call<NetResponseObjectArray<AFileItem>> call = getNetAdapterService().getRadioHostDoc(param);
        doNetAsync(owner, call, callback, "getRadioHostDoc");
        return call;
    }

    @Override
    public Call<NetResponseObject<SingleResult>> doUpForDynamics(String owner, Map<String, Object> param, INetCallback<SingleResult> callback) {
        Call<NetResponseObject<SingleResult>> call = getNetAdapterService().doUp(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<ADynamicsItem>> getMyAnchorDynamicList(String owner, Map<String, Object> param, INetCallback<List<ADynamicsItem>> callback) {
        Call<NetResponseObjectArray<ADynamicsItem>> call = getNetAdapterService().getMyAnchorDynamicList(param);
        doNetAsync(owner, call, callback, "getRelateNews");
        return call;
    }

    /**
     * 获取更多热门视频（短视频）---由静态接口改为动态接口
     *
     * @param owner
     * @param param
     * @param callback
     * @return
     */
    @Override
    public Call<NetResponseObjectArray<NewsItem>> getShortVideos(String owner, Map<String, Object> param, INetCallback<List<NewsItem>> callback) {
        Call<NetResponseObjectArray<NewsItem>> call = getNetAdapterService().getShortVideos(param);
        doNetAsync(owner, call, callback, "getShortVideos");
        return call;
    }

    /**********新闻、直播增加一次点击量与获取点击量的接口依然使用原来的服务器*************/
    @Override
    public Call<NetResponseObject<NewsClickBean>> getNewOrLivingClick(String owner, Map<String, Object> param, INetCallback<NewsClickBean> callback) {
        Call<NetResponseObject<NewsClickBean>> call = getNetAdapterService().getNewOrLivingClick(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<SingleResult>> addNewOrLivingClick(String owner, Map<String, Object> param, INetCallback<SingleResult> callback) {
        Call<NetResponseObject<SingleResult>> call = getNetAdapterService().addNewOrLivingClick(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<ServiceConfigBean>> getServiceConfigData(String owner, String method, INetCallback<ServiceConfigBean> callback) {
        Call<NetResponseObject<ServiceConfigBean>> call = getNetAdapterService().getServiceConfig(getHoleUrl(method));
        doNetObjAsync(owner, call, callback);
        return call;
    }

    /*************************************新增商城相关接口，新的服务地址******************************************/
    @Override
    public Call<NetResponseObject<MessageStateBean>> postGetMessageState(String owner, Map<String, Object> param, INetCallback<MessageStateBean> callback) {
        Call<NetResponseObject<MessageStateBean>> call = getMallNetAdapterService().postGetMessageState(param);
        doNetObjAsync(owner, call, callback);
        return call;

    }

    @Override
    public Call<NetResponseObject<MessageListVo>> postGetMessageList(String owner, Map<String, Object> param, INetCallback<MessageListVo> callback) {
        Call<NetResponseObject<MessageListVo>> call = getMallNetAdapterService().postGetMessageList(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<SingleResult>> postCleanMessage(String owner, Map<String, Object> param, INetCallback<SingleResult> callback) {
        Call<NetResponseObject<SingleResult>> call = getMallNetAdapterService().postCleanMessage(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<SingleResult>> postSetReadMessage(String owner, Map<String, Object> param, INetCallback<SingleResult> callback) {
        Call<NetResponseObject<SingleResult>> call = getMallNetAdapterService().postSetReadMessage(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<IntegralAddBean>> postAddIntegral(String owner, Map<String, Object> param, INetCallback<IntegralAddBean> callback) {
        Call<NetResponseObject<IntegralAddBean>> call = getMallNetAdapterService().postAddIntegral(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<UserInfoBean>> postGetUserData(String owner, Map<String, Object> param
            , INetCallback<UserInfoBean> callback) {
        Call<NetResponseObject<UserInfoBean>> call = getMallNetAdapterService().postGetUserData(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<ConvertRecordBean>> getOrderList(String owner, String userId, int pageIndex
            , String token, INetCallback<List<ConvertRecordBean>> callback) {
        Call<NetResponseObjectArray<ConvertRecordBean>> call = getMallNetAdapterService().getOrderList(userId, pageIndex, token);
        doNetAsync(owner, call, callback, "getOrderList");
        return call;
    }

    @Override
    public Call<NetResponseObject<SignInfo>> getSignInfo(String owner, String userId, String token, INetCallback<SignInfo> callback) {
        Call<NetResponseObject<SignInfo>> call = getMallNetAdapterService().getSignInfo(userId, token);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<GoodsBeanInfo>> getMallStringData(String owner, String url, INetCallback<GoodsBeanInfo> callback) {
        Call<NetResponseObject<GoodsBeanInfo>> call = getMallNetAdapterService().getCommodityInfo(getMallHoleUrl(url));
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<AddrInfo>> getAddrList(String owner, String userId, String token, INetCallback<List<AddrInfo>> callback) {
        Call<NetResponseObjectArray<AddrInfo>> call = getMallNetAdapterService().getAddrList(userId, token);
        doNetAsync(owner, call, callback, "getAddrList");
        return call;
    }


    @Override
    public Call<NetResponseObject<AddrInfoItem>> addAddrInfo(String owner, Map<String, Object> param, INetCallback<AddrInfoItem> callback) {
        Call<NetResponseObject<AddrInfoItem>> call = getMallNetAdapterService().addAddrInfo(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<SingleResult>> setDefaultAddr(String owner, Map<String, Object> param, INetCallback<SingleResult> callback) {
        Call<NetResponseObject<SingleResult>> call = getMallNetAdapterService().setDefaultAddr(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<ResidualIntegral>> addGoodsOrder(String owner, Map<String, Object> param, INetCallback<ResidualIntegral> callback) {
        Call<NetResponseObject<ResidualIntegral>> call = getMallNetAdapterService().addGoodsOrder(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<InvitationRuleVo>> getInvitationRuleList(String owner, String method, INetCallback<InvitationRuleVo> callback) {
        Call<NetResponseObject<InvitationRuleVo>> call = getMallNetAdapterService().getInvitationRuleList(getMallHoleUrl(method));
        doNetObjAsync(owner, call, callback);
        return call;
    }


    @Override
    public Call<NetResponseObject<ServiceCityListVo>> getServiceCityList(String owner, String method, INetCallback<ServiceCityListVo> callback) {
        Call<NetResponseObject<ServiceCityListVo>> call = getMallNetAdapterService().getServiceCityList(getMallHoleUrl(method));
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<SingleResult>> checkInvitationCode(String owner, Map<String, Object> param, INetCallback<SingleResult> callback) {
        Call<NetResponseObject<SingleResult>> call = getMallNetAdapterService().checkInvitationCode(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<ChooseCityVo>> getCityList(String owner, String url, INetCallback<ChooseCityVo> callback) {
        Call<NetResponseObject<ChooseCityVo>> call = getNetAdapterService().getCityList(getHoleUrl(url));
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<ServiceVo>> getServiceData(String owner, Map<String, Object> param, INetCallback<ServiceVo> callback) {
        Call<NetResponseObject<ServiceVo>> call = getMallNetAdapterService().getServiceData(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    /**
     * 添加操作日志
     *
     * @param owner
     * @param param
     * @param callback
     * @return
     */
    @Override
    public Call<NetResponseObject<SingleResult>> addUserOperate(String owner, Map<String, Object> param, INetCallback<SingleResult> callback) {
        Call<NetResponseObject<SingleResult>> call = getLogNetAdapterService().addUserOperate(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    /**
     * 添加直播在线日志
     *
     * @param owner
     * @param param
     * @param callback
     * @return
     */
    @Override
    public Call<NetResponseObject<SingleResult>> addUserOnline(String owner, Map<String, Object> param, INetCallback<SingleResult> callback) {
        Call<NetResponseObject<SingleResult>> call = getLogNetAdapterService().addUserOnline(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObject<AttitudesBean>> getAttitudes(String owner, Map<String, Object> param, INetCallback<AttitudesBean> callback) {
        Call<NetResponseObject<AttitudesBean>> call = getNetAdapterService().getAttitudes(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }

    @Override
    public Call<NetResponseObjectArray<FRebellion>> getTopiciscloseList(String owner, Map<String, Object> param, INetCallback<List<FRebellion>> callback) {
        Call<NetResponseObjectArray<FRebellion>> call = getNetAdapterService().getTopiciscloseList(param);
        doNetAsync(owner, call, callback, "getTimelineList");
        return call;
    }


    @Override
    public Call<NetResponseObject<GovDetailBean>> getOrgInfos(String owner, Map<String, Object> param, INetCallback<GovDetailBean> callback) {
        Call<NetResponseObject<GovDetailBean>> call = getNetAdapterService().getOrgInfos(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }


    @Override
    public Call<NetResponseObject<TopicVo>> getTopicList(String owner, Map<String, Object> param, INetCallback<TopicVo> callback) {
        Call<NetResponseObject<TopicVo>> call = getNetAdapterService().getTopicList(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }


    @Override
    public Call<NetResponseObject<GovBean>> getGovList(String owner, Map<String, Object> param, INetCallback<GovBean> callback) {
        Call<NetResponseObject<GovBean>> call = getNetAdapterService().getGovList(param);
        doNetObjAsync(owner, call, callback);
        return call;
    }


    @Override
    public <T> Call<?> getArrayPost(String method, Map<String, Object> param, INetCallback<List<T>> callback) {
        if (TEST_TAG.equals(method)) {
            doTestAsync(callback);
            return null;
        }
        Call<NetResponseObjectArray<T>> call = null;
        if (param == null || param.size() == 0) {
            call = getNetAdapterService().postArrayNullParam(method);
        } else {
            call = getNetAdapterService().postArrayParam(method, param);
        }
        doNetAsync("", call, callback, method);
        return call;
    }

    private void setRequestUrl(INetCallback callback, Response response) {
        if (callback == null || response == null) {
//            JLog.e("bbnv  callback=" + callback + "   resp=" + response);
            return;
        }
//        int v = 0;
//        String str = null;
        okhttp3.Response r = response.raw();
        if (r != null) {
//            v = 1;
            okhttp3.Request rq = r.request();
            if (rq != null) {
//                v = 2;
                okhttp3.HttpUrl hu = rq.url();
                if (hu != null) {
//                    v = 3;
//                    str = hu.toString();
                    callback.setRequestUrl(hu.toString());
                }
            }
        }
//        JLog.e("bbnc  v=" + v + "   str=" + str);
    }

    private void setPageResponse(INetCallback callback, Object page) {
        try {
            if (callback instanceof IPage) {
                ((IPage) callback).setPageResponse(page);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    private <T> void doTestAsync(INetCallback<List<T>> callback) {
        new NetTestAsync<Void, List<T>>(null, callback) {
            @Override
            protected List<T> doInBackground(Void... params) {

                try {
                    Thread.sleep((long) (50 + Math.random() * 9950));
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                return callbackTemp.doInBackground(null);
            }

            @Override
            protected void onPostExecute(List<T> ts) {
                callbackTemp.onSuc(ts);
                callbackTemp.onEnd();
            }
        }.ex();
    }

    private <T> void doTestObjAsync(INetCallback<T> callback) {
        new NetTestAsync<Void, T>(null, callback) {
            @Override
            protected T doInBackground(Void... params) {

                try {
                    Thread.sleep((long) (50 + Math.random() * 9950));
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                return callbackTemp.doInBackground(null);
            }

            @Override
            protected void onPostExecute(T aVoid) {
                super.onPostExecute(aVoid);
                callbackTemp.onSuc(aVoid);
                callbackTemp.onEnd();
            }
        }.ex();
    }

    private <T> void doTestPageAsync(INetCallback<NetResponseObjectArray<T>> callback) {
        new NetTestAsync<Void, NetResponseObjectArray<T>>(null, callback) {
            @Override
            protected NetResponseObjectArray<T> doInBackground(Void... params) {

                try {
                    Thread.sleep((long) (50 + Math.random() * 9950));
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                return callbackTemp.doInBackground(null);
            }

            @Override
            protected void onPostExecute(NetResponseObjectArray<T> tNetResponseObjectArray) {
                super.onPostExecute(tNetResponseObjectArray);
                callbackTemp.onSuc(tNetResponseObjectArray);
                callbackTemp.onEnd();
            }
        }.ex();
    }


    public static class NetAsync<T, E> extends AsyncTask<Void, Void, Void> {

        protected Call<T> call;
        protected INetCallback<E> callbackTemp;
        protected String ownerString;

        public NetAsync(String owner, Call<T> call, INetCallback<E> callbackTemp) {
            this.call = call;
            this.ownerString = owner;
            this.callbackTemp = callbackTemp;
        }

        @Override
        protected Void doInBackground(Void... params) {
            return null;
        }

        public void ex() {
            executeOnExecutor(THREAD_POOL_EXECUTOR);
        }
    }

    private static class NetTestAsync<T, E> extends AsyncTask<Void, Void, E> {

        protected Call<T> call;
        protected INetCallback<E> callbackTemp;

        public NetTestAsync(Call<T> call, INetCallback<E> callbackTemp) {
            this.call = call;
            this.callbackTemp = callbackTemp;
        }

        @Override
        protected E doInBackground(Void... params) {
            return null;
        }

        public void ex() {
            executeOnExecutor(THREAD_POOL_EXECUTOR);
        }
    }
}
